package cate.game.play.skill.active;

import cate.game.attr.FightAttr;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;

/**
 * 对生命值最低的单位造成390%物理伤害，若目标生命低于40%，则伤害提升25%，若击杀，则回复自身最大生命值的25%
 */
public class 惊鸿剑掠AH extends ActiveHandler{

	private int 检测血量;

	private FightAttr 属性提升;

	private double 恢复血量;


	//检测血量=4000&属性提升=？？&恢复血量=2500
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		检测血量 = args.getInt("检测血量", 0);
		属性提升 = new FightAttr(args.get("属性提升"));
		恢复血量 = args.getWDouble("恢复血量",0d);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		检测血量 += args.getInt("检测血量", 0);
	}

	@Override
	public void beforeSingleEffect(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (target.attr.total().hpCurRate() <= 检测血量) {
			effect.getTargetCtx(target.getPid()).addActorAttr(属性提升);
		}
	}

	@Override
	public void afterSingleEffect(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (target.isDead()) {
			skill.owner.attr.passiveHeal(action, skill.owner.attr.total().hpTotal() * 恢复血量);
		}
	}
}
